package cn.gson.crm.control.callback;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSONArray;

import cn.gson.crm.control.base.BaseServlet;
import cn.gson.crm.model.dao.CallbackDao;

@WebServlet("/callback/add")

public class CallbackAddServlet extends BaseServlet{
	private CallbackDao callbackDao = new CallbackDao();
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@Override
	protected void get(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String name = request.getParameter("name");
		int id = callbackDao.getStuId(name);
		request.setAttribute("id", id);
		response.setContentType("application/json;charset=utf-8");
    	String jsonStr = JSONArray.toJSONString(id);
        //输出结果
        response.getWriter().append(jsonStr);
	}
	
	@Override
	protected void post(HttpServletRequest request, HttpServletResponse response) throws Exception {
		
		String stuId =  request.getParameter("stuid");
		String callbackCompany =  request.getParameter("callbackCompany");
		String callbackMoney =  request.getParameter("callbackMoney");
		String callbackPosition =  request.getParameter("callbackPosition");
		String callbackContent =  request.getParameter("callbackContent");
		String callbackTime =  request.getParameter("callbackTime");
		System.out.println(stuId);
		callbackDao.insertCallback(callbackCompany, callbackMoney, stuId, callbackPosition,callbackContent, callbackTime);
		forward("../../callback/manager");
	}

}

